package com.etc.dao.impl;

import com.etc.dao.AdminDao;
import com.etc.entity.Admin;
import com.etc.util.DBUtil;

import java.util.List;

public class AdminDaoImpl implements AdminDao {

    @Override
    public Admin getAdmin(String adminname, String adminpwd) {
        //select * from xx where adminname = ? and adminpwd= ? =>
        String sql ="select * from tbl_admin where adminname = ? and adminpwd= ?";
        List<Admin> list = DBUtil.exQuery(sql,Admin.class,adminname,adminpwd);
        //如果集合为空，表示没有找到匹配记录
        if(list.isEmpty()){
            return null;
        }
        //返回的是集合中的第一个元素
        return list.get(0);
    }
}
